package com.lc.zpyh.ui.activity.mine;

import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;

import com.hjq.bar.TitleBar;
import com.hjq.http.EasyHttp;
import com.hjq.http.listener.HttpCallback;
import com.lc.zpyh.R;
import com.lc.zpyh.app.AppActivity;
import com.lc.zpyh.http.request.AgreementApi;
import com.lc.zpyh.http.response.AgreementBean;

import butterknife.BindView;
import butterknife.ButterKnife;

public class XieYiActivity extends AppActivity {
    @BindView(R.id.tv_xieyi)
    TextView tvXieyi;
    @BindView(R.id.topbar)
    TitleBar topbar;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_xieyi;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        topbar.setTitle(getIntent().getStringExtra("title"));
        xieyi();
    }

    private void xieyi() {

        EasyHttp.get(this)
                .api(new AgreementApi()).request(new HttpCallback<AgreementBean>(this) {


            @Override
            public void onSucceed(AgreementBean data) {
                if (data.getCode() == 0) {
                    if (getIntent().getStringExtra("title").equals("用户协议")) {
                        tvXieyi.setText(Html.fromHtml(data.getList().getUserAgreement()));
                    } else {
                        tvXieyi.setText(Html.fromHtml(data.getList().getPrivacyPolicy()));
                    }
                }
            }
        });


    }
}
